package com.workflow.service.impl;

import java.util.Date;
import java.util.List;

import com.common.util.AbstractManager;
import com.common.util.PagerModel;
import com.workflow.bean.Listsales;
import com.workflow.service.ListsalesService;

public class ListsalesServiceImpl extends AbstractManager implements
		ListsalesService {

	public void addListsales(Listsales listsales) {
		String hql = "select nvl(max(listid),0) from Listsales ";
		
		Long listid = (Long)this.getHibernateTemplate().find(hql).get(0);
		listid += 1;
		listsales.setListid(listid);
		listsales.setSalesdate(new Date());
		
		this.getHibernateTemplate().save(listsales);
	}

	@SuppressWarnings("unchecked")
	public List<Listsales> findAllListsales() {
		String hql = "from Listsales ls order by ls.listid";
		return this.getHibernateTemplate().find(hql);
	}

	public Listsales findListsales(long listid) {
		return (Listsales) this.getHibernateTemplate().load(Listsales.class, listid);
	}

	public PagerModel findListsalesForPager() {
		String hql = "from Listsales ls order by ls.listid";
		return searchPaginated(hql);
	}

	public void removeListsales(long listid) {
		Listsales listsales = (Listsales)this.getHibernateTemplate().load(Listsales.class, listid);
		if(listsales != null) {
			this.getHibernateTemplate().delete(listsales);
		}
	}

	public void updateListsales(Listsales listsales) {
		this.getHibernateTemplate().update(listsales);
	}
	
	
}
